<!DOCTYPE html>
<html>
<head>
    <title>代理添加</title>
    {{template "inc/mate.html" .}}
    {{template "inc/easyui_css.html" .}}
    {{template "inc/ie_supper.html" .}}
</head>
<body>
		<form id="ff" method="post" action="{{.baseUrl}}/man/addAgent" class="easyui-form" data-options="novalidate:true,ajax:false" style="padding:30px 45px;">
			<div style="margin-bottom:20px; margin-left: -30px; margin-top: -30px">
		        <a href="{{.baseUrl}}/man" class="easyui-linkbutton" style="width:100px;">返回列表</a>
		    </div>
		    <div style="margin-bottom:20px;">
			    <fieldset style="border-width: 1px 0px 0px 0px; margin-left: -30px;">
			    	<legend>添加代理信息</legend>
			    </fieldset>
			</div>
			<div style="margin-bottom:20px">
		        <input class="easyui-textbox" name="name" style="width:300px" data-options="label:'用户名:',required:true,validType:'unamevali',missingMessage:'用户名不可以为空',invalidMessage:'用户名必须是5位及以上字母数字符组成'" />
		    </div>
		    <div style="margin-bottom:20px">
		        <input class="easyui-passwordbox" name="pwd" id='txtpwd' style="width:300px" data-options="label:'密码:',required:true,validType:'length[6,12]',missingMessage:'密码不可以为空',invalidMessage:'密码必须6到12位'" />
		    </div>
		    <div style="margin-bottom:20px">
		        <input class="easyui-passwordbox" name="repwd" style="width:300px" data-options="label:'重输密码:',required:true,validType:'myequals[\'txtpwd\']',missingMessage:'重输密码不可以为空',invalidMessage:'两次输入的密码不一致'" />
		    </div>
		    <div style="margin-bottom:20px">
	            <input class="easyui-numberspinner" value="0" name="price" data-options="label:'代理价格：',increment:1,min:0,prefix:'$ ',required:true"  style="width:180px">
	        </div>
	        <div style="margin-bottom:20px">
	            <input id="region_lev1" name="recode1" value="" style="width:230px" />
	            <input id="region_lev2" name="recode2" value="" style="width:230px" />
	            <input id="region_lev3" name="recode3" value="" style="width:230px" />
	        </div>
	        <div style="margin-bottom:20px">
	        	<a href="javascript:void(0)" class="easyui-linkbutton" id="btn_submit" style="width:100px; border-color: #4cae4c; background-image: linear-gradient(rgb(76,174,76) 0px, rgb(68,157,68) 100%);">添加代理</a>
	        	<a href="javascript:void(0)" class="easyui-linkbutton" id="btn_clear" style="width:100px;">重新填写</a>
	        </div>
		</form>
</body>
</html>
{{template "inc/easyui_js.html" .}}
<script type="text/javascript" src="{{.staticResourceUrl}}/js/easyui_validate.js"></script>
<script type="text/javascript" charset="UTF-8">
	$(document).ready(function(){
		var allHeight=document.documentElement.clientHeight;
		allHeight-=20;
		document.body.style.height = allHeight+"px";
		var lev1_val="";
		var lev2_val="";
		var reload_lev3=function(){
			$("#region_lev3").combobox({
				method:'post',
				url:"{{.baseUrl}}/basefun/findRegions",
				valueField:"RegionCode",
				textField:"RegionName",
				required:true,
				validType:'regionval',
				editable:false,
				missingMessage:'请选择代理区域',
				invalidMessage:'1请1选择代理区域',
				queryParams:{"lve":3,"regionCode":lev2_val}
			});
			$("#region_lev3").combobox('disableValidation');
		};
		var reload_lev2=function(){
			$("#region_lev2").combobox({
				method:'post',
				url:"{{.baseUrl}}/basefun/findRegions",
				valueField:"RegionCode",
				textField:"RegionName",
				editable:false,
				required:true,
				validType:'regionval',
				missingMessage:'请选择代理区域',
				invalidMessage:'1请选择代理区域',
				queryParams:{"lve":2,"regionCode":lev1_val},
				onSelect:function(rec){
					lev2_val=rec.RegionCode;
					if(lev2_val==""){
						return;
					}
					reload_lev3();
				}
			});
			$("#region_lev2").combobox('disableValidation');
		};
		//代理区域第一级
		$("#region_lev1").combobox({
			label:'代理区域',
			method:'post',
			url:"{{.baseUrl}}/basefun/findRegions",
			valueField:"RegionCode",
			textField:"RegionName",
			editable:false,
			required:true,
			validType:'regionval',
			missingMessage:'请选择代理区域',
			invalidMessage:'1请选择代理区域',
			queryParams:{"lve":1},
			onSelect:function(rec){
				lev1_val=rec.RegionCode;
				if(lev1_val==""){
					return;
				}
				reload_lev2();
			}
		});
		$("#region_lev1").combobox('disableValidation');
		reload_lev2();
		reload_lev3();
        $("#btn_submit").click(function(){
        	$("#region_lev1").combobox('enableValidation');
        	$("#region_lev2").combobox('enableValidation');
        	$("#region_lev3").combobox('enableValidation');
            $('#ff').form('submit',{
                onSubmit:function(){
                    return $(this).form('enableValidation').form('validate');
                }
            });
        });
        $("#btn_clear").click(function(){
        	$("#region_lev1").combobox('disableValidation');
        	$("#region_lev2").combobox('disableValidation');
        	$("#region_lev3").combobox('disableValidation');
            $("#ff").form({
                novalidate:true
            });
            $("#ff").form("clear");
        });
    });
</script>

